//
//  CXSpecialCollectionViewCell.m
//  GiftThat
//
//  Created by ChuXiang on 16/1/13.
//  Copyright © 2016年 ChuXiang. All rights reserved.
//

#import "CXSpecialCollectionViewCell.h"
@interface CXSpecialCollectionViewCell ()

@end
@implementation CXSpecialCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        self.deleteButton = [UIButton buttonWithType:UIButtonTypeSystem];
        [self.deleteButton setImage:[[UIImage imageNamed:@"delete"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] forState:UIControlStateNormal];
        [self.deleteButton addTarget:self action:@selector(deleteButtonDidPress:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:self.deleteButton];
    }
    return self;
}

- (void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes {
    [super applyLayoutAttributes:layoutAttributes];
    self.deleteButton.frame = CGRectMake(self.titleLabel.right - 10, self.titleLabel.top - 10, 20, 20);

}

- (void)deleteButtonDidPress:(UIButton *)sender {
    
    self.deleteBlock();
    
    
}



- (void)setTitle:(NSString *)name withIndexPath:(NSString *)index{
    if (name) {
        self.titleLabel.text = name;
    }
    if ([index isEqualToString:@"10"]) {
        self.deleteButton.frame = CGRectZero;
        self.titleLabel.layer.borderWidth = 0;
        self.titleLabel.textColor = [UIColor grayColor];
    }else{
        self.titleLabel.layer.borderWidth = 0.5;
        self.titleLabel.textColor = [UIColor blackColor];
    }

}
@end
